<template>
    <view>

        <daya-clone-navbar :prop_clone_navbar="clone_navbar" :prop_is_ipx="is_ipx"/>

        <view @tap="yczz" class="sq_screen" v-if="hydl"></view>
        <view class="sq_box" v-if="hydl">
            <view class="sq_title">需要您的授权</view>
            <view class="sq_title1">为了提供更好的服务</view>
            <view class="sq_title1">请在稍后的提示框中点击“允许”</view>
            <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/sqimg.png"></image>
            <button @getuserinfo="bindGetUserInfo" class="btn_ok" openType="getUserInfo" :style="'color:#fff;background:' + color">我知道了</button>
        </view>
        <view class="container">
            <view class="font">
                <view class="logs_header" :style="'background:' + color">
                    <view class="logs_img">
                        <image class="logs_imgs" :src="avatarUrl"></image>
                        <view class="logs_name">
                            <view class="logs_name1">{{ nickName }}</view>
                        </view>
                    </view>
                    <image @tap="tzhy" class="blackjt" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/jiantou.png" v-if="system.hygn == '1' && system.is_hy == '1'"></image>
                </view>
                <view>
                    <!-- #ifdef MP-WEIXIN -->
                    <!-- [miniprogram-to-uniapp] 公众号关注组件 仅微信小程序支持 -->
                    <official-account></official-account>
                    <!-- #endif -->

                    <!-- #ifndef MP-WEIXIN -->
                    <view>当前为非微信小程序环境，不支持公众号关注组件，请自行调整当前节点内容！</view>
                    <!-- #endif -->
                </view>
                <view class="banner" v-if="lblist.length != 0">
                    <view class="swiper-container">
                        <swiper :autoplay="true" :circular="true" class="swiper" duration="500" :indicatorDots="lblist.length > 1" interval="5000">
                            <swiper-item :data-index="index" v-for="(item, index) in lblist" :key="item.unique">
                                <image
                                    @tap="jumps"
                                    class="img"
                                    :data-appid="item.appid"
                                    :data-id="item.id"
                                    :data-name="item.title"
                                    :data-src="item.src"
                                    :data-type="item.item"
                                    :data-wb_src="item.src2"
                                    :src="item.logo"
                                ></image>
                            </swiper-item>
                        </swiper>
                    </view>
                </view>
                <ad :unitId="item.src" v-for="(item, index) in dbllz" :key="index"></ad>
                <view class="logs_order">
                    <view @tap="wddz" class="logs_center">
                        <view class="logs_centerimg">
                            <image class="center_map" mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/personal/dizhi.png"></image>
                            <view>收货地址</view>
                        </view>
                        <image class="center_img" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/blackjt.png"></image>
                    </view>
                    <navigator class="logs_center" url="../qd/qd">
                        <view class="logs_centerimg">
                            <image class="center_map" mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/personal/jifen.png"></image>
                            <view>每日签到</view>
                        </view>
                        <image class="center_img" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/blackjt.png"></image>
                    </navigator>
                </view>
                <ad :unitId="item.src" v-for="(item, index) in zbllz" :key="index"></ad>
                <view class="logs_seller">
                    <view @tap="help" class="logs_center" style="border-bottom: 0">
                        <view class="logs_centerimg">
                            <image class="center_map" mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/personal/kefu.png"></image>
                            <view>在线客服</view>
                        </view>
                        <image class="center_img" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/blackjt.png"></image>
                    </view>
                </view>
                <view class="copyright">
                    <navigator :appId="system.tz_appid" class="copyright_logo" extraData="" openType="navigate" path="" target="miniProgram" version="release">
                        <image class="copyright_img" mode="aspectFill" :src="system.bq_logo"></image>
                        <view class="copyright_text">{{ system.bq_name }}</view>
                    </navigator>
                    <view class="copyright_txt">{{ system.support }}</view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var app = getApp();
var util = require('../../utils/util.js');
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            carte: [
                {
                    img1: 'https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/personal/kefu.png',
                    name: '客服与投诉',
                    img2: '',
                    margin: 'margin_top',
                    border: 'border_bottom',
                    bindtap: 'customer'
                },
                {
                    img1: 'https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/personal/bangzhu.png',
                    name: '帮助中心',
                    img2: '',
                    border: 'border_bottom',
                    bindtap: 'help'
                }
            ],

            top: '-420',
            yhnum: '',

            system: {
                hygn: '',
                is_hy: '',
                tz_appid: '',
                bq_logo: '',
                bq_name: '',
                support: ''
            },

            fxset: '',
            qdset: '',
            lblist: '',
            dbllz: '',
            zbllz: '',
            userInfo: '',
            hydl: false,
            avatarUrl: '',
            nickName: '',


            color: ''
        };
    },
    onLoad: function (t) {
        app.globalData.setNavigationBarColor(this);
        this.appPageOnLoad(app);
        this.changeData();
        var that = this;
        var e = uni.getStorageSync('users').id;
        console.log(e);
        app.globalData.util.request({
            url: 'entry/wxapp/MyCoupons',
            cachetime: '0',
            data: {
                user_id: e
            },
            success: function (t) {
                console.log(t.data);
                that.setData({
                    yhnum: t.data.length
                });
            }
        });
        app.globalData.util.request({
            url: 'entry/wxapp/system',
            cachetime: '0',
            success: function (t) {
                console.log(t);
                that.setData({
                    system: t.data
                });
            }
        });
        app.globalData.util.request({
            url: 'entry/wxapp/CheckRetail',
            cachetime: '0',
            success: function (t) {
                console.log(t);
                that.setData({
                    fxset: t.data
                });
            }
        });
        app.globalData.util.request({
            url: 'entry/wxapp/Signset',
            cachetime: '0',
            success: function (t) {
                console.log('签到设置', t);
                that.setData({
                    qdset: t.data
                });
            }
        });
        app.globalData.util.request({
            url: 'entry/wxapp/ad',
            cachetime: '0',
            success: function (t) {
                console.log(t);
                for (var e = [], a = 0; a < t.data.length; a++) {
                    if ('7' == t.data[a].type) {
                        e.push(t.data[a]);
                    }
                }
                console.log(e);
                that.setData({
                    lblist: e
                });
            }
        });
        app.globalData.util.request({
            url: 'entry/wxapp/Llz',
            cachetime: '0',
            data: {
                type: '3,4'
            },
            success: function (t) {
                console.log(t);
                for (var e = [], a = [], n = 0; n < t.data.length; n++) {
                    if (3 == t.data[n].type) {
                        e.push(t.data[n]);
                    }
                    if (4 == t.data[n].type) {
                        a.push(t.data[n]);
                    }
                }
                that.setData({
                    dbllz: e,
                    zbllz: a
                });
            }
        });
        uni.getSystemInfo({
            success: function (t) {
                console.log(t.model);
                console.log(t.pixelRatio);
                console.log(t.windowWidth);
                console.log(t.windowHeight);
                console.log(t.language);
                console.log(t.version);
                console.log(t.platform);
                if ('android' != t.platform) {
                    that.setData({
                        top: '-330'
                    });
                }
            }
        });
    },
    onReady: function () {},
    onShow: function () {
        var that = this;
        var t = uni.getStorageSync('users').id;
        var n = util.formatTime(new Date()).substring(0, 10).replace(/\//g, '-');
        console.log(n.toString());
        app.globalData.util.request({
            url: 'entry/wxapp/UserInfo',
            cachetime: '0',
            data: {
                user_id: t
            },
            success: function (t) {
                console.log(t);
                if ('' != t.data.dq_time && t.data.dq_time >= n.toString()) {
                    t.data.ishy = 1;
                }
                that.setData({
                    userInfo: t.data
                });
            }
        });
    },
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    methods: {
        wdsc: function () {
            uni.navigateTo({
                url: '../extra/wdsc'
            });
        },

        wddd: function () {
            uni.navigateTo({
                url: '../wddd/order'
            });
        },

        wddz: function () {
            uni.navigateTo({
                url: '../wddz/xzdz'
            });
        },

        wdyy: function () {
            uni.navigateTo({
                url: '../reserve/order'
            });
        },

        wdqg: function () {
            uni.navigateTo({
                url: '../xsqg/order'
            });
        },

        wdpt: function () {
            uni.navigateTo({
                url: '../collage/order'
            });
        },

        wdyhq: function () {
            uni.navigateTo({
                url: 'myyhq'
            });
        },

        help: function () {
            uni.navigateTo({
                url: '../my/bzzx'
            });
        },

        seller: function () {
            var t = uni.getStorageSync('users').id;
            app.globalData.util.request({
                url: 'entry/wxapp/CheckRz',
                cachetime: '0',
                data: {
                    user_id: t
                },
                success: function (t) {
                    console.log(t.data);
                    if (0 != t.data) {
                        if (1 == t.data.state) {
                            uni.showModal({
                                title: '',
                                content: '系统正在审核中'
                            });
                        } else {
                            if (2 == t.data.state) {
                                uni.setStorageSync('sjdsjid', t.data.id);
                                uni.navigateTo({
                                    url: '../sjzx/wmdd/wmdd'
                                });
                            } else {
                                if (3 == t.data.state) {
                                    uni.showModal({
                                        title: '',
                                        content: '您的合作申请已被拒绝，点击确定进行编辑',
                                        success: function (t) {
                                            if (t.confirm) {
                                                uni.navigateTo({
                                                    url: '../ruzhu/index?state=3'
                                                });
                                            }
                                        }
                                    });
                                } else {
                                    uni.showModal({
                                        title: '',
                                        content: '您的合作已经到期,请联系平台管理员续费'
                                    });
                                }
                            }
                        }
                    } else {
                        uni.navigateTo({
                            url: '../sjzx/login'
                        });
                    }
                }
            });
        },

        fx: function () {
            uni.navigateTo({
                url: '../distribution/index'
            });
        },

        jfsc: function () {
            uni.navigateTo({
                url: '../integral/integral'
            });
        },

        czzx: function () {
            uni.navigateTo({
                url: '../wallet/walletadd'
            });
        },

        tzhy: function () {
            uni.navigateTo({
                url: '../hyk/hyk'
            });
        },

        bindGetUserInfo: function (t) {
            console.log(t);
            if ('getUserInfo:ok' == t.detail.errMsg) {
                this.setData({
                    hydl: false
                });
                this.changeData();
            }
        },

        changeData: function () {
            var that = this;
            uni.getSetting({
                success: function (t) {
                    console.log(t);
                    if (t.authSetting['scope.userInfo']) {
                        uni.getUserInfo({
                            success: function (t) {
                                console.log(t);
                                app.globalData.util.request({
                                    url: 'entry/wxapp/login',
                                    cachetime: '0',
                                    data: {
                                        openid: getApp().globalData.getOpenId,
                                        img: t.userInfo.avatarUrl,
                                        name: t.userInfo.nickName
                                    },
                                    header: {
                                        'content-type': 'application/json'
                                    },
                                    dataType: 'json',
                                    success: function (t) {
                                        console.log('用户信息', t);
                                    }
                                });
                                var e = t.userInfo;
                                console.log(e);
                                that.setData({
                                    avatarUrl: e.avatarUrl,
                                    nickName: e.nickName
                                });
                            }
                        });
                    } else {
                        console.log('未授权过');
                        that.setData({
                            hydl: true
                        });
                    }
                }
            });
        },

        jumps: function (t) {
            var e = t.currentTarget.dataset.id;
            var a = t.currentTarget.dataset.name;
            var n = t.currentTarget.dataset.appid;
            var o = t.currentTarget.dataset.src;
            var s = t.currentTarget.dataset.wb_src;
            var i = t.currentTarget.dataset.type;
            console.log(e, a, n, o, s, i);
            if (1 == i) {
                console.log(o);
                uni.navigateTo({
                    url: o
                });
            } else {
                if (2 == i) {
                    uni.setStorageSync('vr', s);
                    uni.navigateTo({
                        url: '../car/car'
                    });
                } else {
                    if (3 == i) {
                        uni.navigateToMiniProgram({
                            appId: n
                        });
                    }
                }
            }
        },

        feedback: function (t) {
            uni.navigateTo({
                url: 'feedback'
            });
        },

        wallet: function (t) {
            uni.navigateTo({
                url: '../wallet/wallet'
            });
        },

        set_up: function (t) {
            uni.navigateTo({
                url: 'set_up'
            });
        },

        receive: function (t) {
            uni.navigateTo({
                url: 'receive'
            });
        },

        integral: function (t) {
            uni.navigateTo({
                url: '../integral/myintegral'
            });
        },

        sign_in: function (t) {
            uni.navigateTo({
                url: 'rankings'
            });
        },

        sjrz: function (t) {
            var e = uni.getStorageSync('users').id;
            app.globalData.util.request({
                url: 'entry/wxapp/CheckRz',
                cachetime: '0',
                data: {
                    user_id: e
                },
                success: function (t) {
                    console.log(t.data);
                    if (0 != t.data) {
                        if (1 == t.data.state) {
                            uni.showModal({
                                title: '',
                                content: '系统正在审核中'
                            });
                        } else {
                            if (2 == t.data.state) {
                                uni.showModal({
                                    title: '',
                                    content: '您已经合作过了'
                                });
                            } else {
                                if (3 == t.data.state) {
                                    uni.showModal({
                                        title: '',
                                        content: '您的合作申请已被拒绝，点击确定进行编辑',
                                        success: function (t) {
                                            if (t.confirm) {
                                                uni.navigateTo({
                                                    url: '../ruzhu/index?state=3'
                                                });
                                            }
                                        }
                                    });
                                } else {
                                    uni.showModal({
                                        title: '',
                                        content: '您的合作已经到期,请联系平台管理员续费'
                                    });
                                }
                            }
                        }
                    } else {
                        uni.navigateTo({
                            url: '../ruzhu/index'
                        });
                    }
                }
            });
        },

        yczz() {
            console.log('占位：函数 yczz 未声明');
        }
    }
};
</script>
<style>
@import './gsmy.css';
</style>
